const LOCAL_LANG: langType = 'zh-cn';
const DEFAULT_LANG: langType = 'en-uk';

type langType = 'zh-cn' | 'zh-hk' | 'en-uk' 

type lang = {
  [key in langType]: IText;
};

interface IText {
  user?: {
    name: string,
  },
  form?: {
    year: string,
    day: string,
  },
  [key: string]: any;
}

const data: lang = {
  "zh-cn": {
    user: { name: "马" },
    form: {
      year: "年",
      day: "天",
    }
  },
  "zh-hk": {
    user: { name: "馬" },
    form: {
      year: "年",
      day: "日",
    }
  },
  "en-uk": {
    user: { name: "Horse" },
    form: {
      year: "year",
      day: "day",
    }
  }
}


export const text: IText = new Proxy(data, {
  get: function(target: lang, propKey: string) {
    if (propKey in target[LOCAL_LANG]) {
      return target[LOCAL_LANG][propKey];
    } else {
      // LOCAL_LANG 不存在，使用默认语言
      return target[DEFAULT_LANG][propKey]
    }
  }
})